﻿@*YoursLC有源低代码 CreateTime:2022-04-04 11:37:55 添加或编辑-此文件放置于Views/Data03/中*@

@using Think9.Models;
@model Think9.Models.Data03Model
@{ ViewBag.Title = "Add";
	Layout = "~/Areas/Shared/_LayuiForm.cshtml"; }

@*Data03员工*@

<form class="layui-form" lay-filter="formUser">
<input style="display:none" id="_userid" value="@ViewBag.userid">@*用户id*@
<input style="display:none" id="_attachmentId">@*附件id*@
<input style="display:none" id="_type" value="@ViewBag.type">@*add或edit*@
<input style="display:none" id="prc_fid" value="@ViewBag.fid">@*当前流程编码*@
<input style="display:none" id="prc_id"  value="@ViewBag.prcid">@*当前流程步骤id*@
<input style="display:none" id="prc_no"  value="@ViewBag.prcno">@*当前流程步骤编码*@
<input style="display:none" id="sys_plit" value="@ViewBag.split">@*多选框字符分割*@
<input style="display:none" id="sys_listid" value="@ViewBag.listid">
<input style="display:none" id="Pu_value">
<input style="display:none" id="Pu_tbid">
<input style="display:none" id="Pu_indexid">
<input style="display:none" id="Pu_id">
<input style="display:none" id="Pu_v">
<div class="layui-form">
 <div class="layui-form-item"  style="text-align: right;">
	<div class="layui-btn-group">
			@*<button type="button" class="layui-btn" id="sys_att">附件</button>*@
			<button type="button" class="layui-btn" lay-submit lay-filter="edit">保存</button>
			@*<button type="button" class="layui-btn" lay-submit lay-filter="next">转交</button>*@
			@*<button type="button" class="layui-btn" lay-submit lay-filter="finish">结束</button>*@
	 </div>
  </div>

	<div class="layui-row layui-col-space15">
		<div class="layui-col-md6">
			<label class="layui-form-label">员工编码</label>
			<div class="layui-input-block">
				<input type='text' name='inEmployeeCode' id='inEmployeeCode' autocomplete='off' class='layui-input'  maxlength='30'    placeholder='员工编码'>
				</div>
			</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">员工姓名</label>
			<div class="layui-input-block">
				<input type='text' name='inEmployeeName' id='inEmployeeName' autocomplete='off' class='layui-input'  maxlength='30'    placeholder='员工姓名'>
				</div>
			</div>
	 </div>
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md6">
			<label class="layui-form-label">员工部门</label>
			<div class="layui-input-block">
				<select id="inEmployeeDepartment" name="inEmployeeDepartment"  lay-filter = "inEmployeeDepartment"  >
					<option value="">==请选择==</option>
						@foreach (valueTextEntity item in ((IEnumerable<valueTextEntity>)ViewBag.SelectList).Where(x => x.ClassID == "inEmployeeDepartment"))
						{
							 <option value="@item.Value">@item.Text</option>
						}
				</select>
				</div>
			</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">员工岗位</label>
			<div class="layui-input-block">
				<select id="inEmployeePosition" name="inEmployeePosition"  lay-filter = "inEmployeePosition"  >
					<option value="">==请选择==</option>
						@foreach (valueTextEntity item in ((IEnumerable<valueTextEntity>)ViewBag.SelectList).Where(x => x.ClassID == "inEmployeePosition"))
						{
							 <option value="@item.Value">@item.Text</option>
						}
				</select>
				</div>
			</div>
	 </div>
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md6">
			<label class="layui-form-label">入职日期</label>
			<div class="layui-input-block">
				<input  name='inEntryDate' id='inEntryDate'  class='layui-input' autocomplete='off'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})" placeholder='入职日期'   lay-verify='date' >
			</div>
		</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">基本工资</label>
			<div class="layui-input-block">
				<input type='text' name='inBasePay' id='inBasePay' autocomplete='off' class='layui-input'   maxlength='15'    lay-verify='number'   placeholder='基本工资'>
			</div>
		</div>
	 </div>
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md6">
			<label class="layui-form-label">绩效工资</label>
			<div class="layui-input-block">
				<input type='text' name='inMeritPay' id='inMeritPay' autocomplete='off' class='layui-input'   maxlength='15'    lay-verify='number'   placeholder='绩效工资'>
			</div>
		</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">岗位工资</label>
			<div class="layui-input-block">
				<input type='text' name='inPostSalary' id='inPostSalary' autocomplete='off' class='layui-input'   maxlength='15'    lay-verify='number'   placeholder='岗位工资'>
			</div>
		</div>
	 </div>
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md6">
			<label class="layui-form-label">职称津贴</label>
			<div class="layui-input-block">
				<input type='text' name='inTitleAllowance' id='inTitleAllowance' autocomplete='off' class='layui-input'   maxlength='15'    lay-verify='number'   placeholder='职称津贴'>
			</div>
		</div>
		<div class="layui-col-md6">
			<label class="layui-form-label">调薪时间</label>
			<div class="layui-input-block">
				<input  name='inSalaryAdjustmentTime' id='inSalaryAdjustmentTime'  class='layui-input' autocomplete='off'  onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})" placeholder='调薪时间'   lay-verify='date' >
			</div>
		</div>
	 </div>
</div>

</form>
<script>
	layui.config({
		base: '/self_js/'  /*自定义的js文件 位于wwwroot/self_js文件夹中*/
	});
	layui.use(["form", "exLayer", "exUtils",  "table", "Data03"], function () {
		let form = layui.form;
		let layer = layui.layer;
		let table = layui.table;
		let exLayer = layui.exLayer;
		let exUtils = layui.exUtils;
		let mySelf = layui.Data03;

		let $ = layui.$;
		form.render();

		getFormVal();//设置多选框和图片的显示--无多选框和图片可删除
		lockForEditing();//编辑时锁定
		//根据步骤编码设置控件disabled
		mySelf.setStateByFlow($('#prc_no').val());
		//赋值--不包括多选框和图片
		form.val("formUser", {
			"inEmployeeCode": "@Model.inEmployeeCode"
			,"inEmployeeName": "@Model.inEmployeeName"
			,"inEmployeeDepartment": "@Model.inEmployeeDepartment"
			,"inEmployeePosition": "@Model.inEmployeePosition"
			,"inEntryDate": showDate("@Model.inEntryDate")
			,"inBasePay": "@Model.inBasePay"
			,"inMeritPay": "@Model.inMeritPay"
			,"inPostSalary": "@Model.inPostSalary"
			,"inTitleAllowance": "@Model.inTitleAllowance"
			,"inSalaryAdjustmentTime": showDate("@Model.inSalaryAdjustmentTime")
		});
		//设置多选框和图片的显示
		function getFormVal() {


		}
		//编辑时锁定
		function lockForEditing() {
			if ($('#_type').val() == 'edit') {
				$('#inEmployeeCode').attr('disabled','disabled');//员工编码
			}
		}



		//点击保存按钮
		form.on("submit(edit)", function (data) {
			var _gridList = [];
			mySelf.foreachGridTable(_gridList);//遍历子表table取数
			exUtils.ajax('/Data03/SaveData', 'post', {
				model: data.field, 'gridlist': _gridList, listid: $('#sys_listid').val(), prcno: $('#prc_no').val(), type: $('#_type').val(), att: $('#_attachmentId').val() }, true).done(function (response) {
				exLayer.greenTickMsg(response.message, function () {
				$(window.parent.document).find('#search').click();
				parent.layer.close(parent.layer.getFrameIndex(window.name));
			});
		}).fail(function (error) {
			console.log(error);
		});
			return false;
		});




		//弹出页面关闭后为控件赋值 无弹出页面可删除
		$("#Pu_value").click(function () {
			mySelf.getValueFromPopUp();//控件赋值
			readValue();//执行数据读取
		});

		//数据读取
		function readValue() {
			var _gridList = [];
			mySelf.getSelectGridTable(_gridList, $('#Pu_tbid').val(), $('#Pu_id').val());

			var _controlsList = [];
			$.each($("form").serializeArray(), function (i, field) {
				_controlsList.push({ ControlID: field.name, ControlValue: field.value });
			  /*  alert(field.name + ":" + field.value);*/
			});
			//还要将禁用的控件push

			exUtils.ajax("/Data03/AfterControlSelect", "post", { controlslist: _controlsList, "gridlist": _gridList, id: $('#Pu_id').val(), tbid: $('#Pu_tbid').val(), indexid: $('#Pu_indexid').val(), value: $('#Pu_value').val() }, true).done(function (response) {
				lists = response.list;
				console.log(lists);
				//使用后台返回的lists，为控件赋值
				mySelf.setValueByList(lists);

				form.render();//一定要加
			}).fail(function (error) {
				console.log(error);
			});

			return false;
		}

	});
</script>